import java.util.ArrayDeque;
import java.util.Deque;

/**
 * Created with IntelliJ IEDA.
 * Description:
 * User:86186
 * Date:2022-10-05
 * Time:16:48
 */

/**
 * 力扣剑指offer09:用两个栈实现队列
 */

class CQueue1 {
    Deque<Integer> inStack;
    Deque<Integer> outStack;

    public CQueue1() {
        inStack = new ArrayDeque<>();
        outStack = new ArrayDeque<>();
    }

    public void appendTail(int value) {
        inStack.push(value);
    }

    public int deleteHead() {
        if (outStack.isEmpty()) {
            if (inStack.isEmpty()) {
                return -1;
            }
            in2out();
        }
        return outStack.pop();
    }

    private void in2out() {
        while (!inStack.isEmpty()) {
            outStack.push(inStack.pop());
        }
    }
}
public class CQueue {

}
